{% extends '_otp.html' %}

{% block title %}
    验证身份
{% endblock %}


{% block body_title %}
    验证身份
{% endblock %}

{% block body_content %}
    <div class="cls-content-sm" style="width: 215px; min-width: 215px">
        <form name="verifyForm">
            <div class="form-group" style="margin-bottom: 25px">
                <input type="text" name="username" value="{{ current_user.username }}"  class="form-control" readonly>
            </div>
            <div class="form-group" style="margin-bottom: 25px">
                <input type="password" name="password" class="form-control" placeholder="密码">
            </div>
            <button class="btn btn-primary btn-sm btn-block">下一步</button>
        </form>
    </div>
{% endblock %}

{% block buttom_js %}]
    <!--bees-->
    <script src="{{ url_for('static', filename='js/bees.js') }}"></script>

    <script type="text/javascript">

        $(function () {
            $('form[name="verifyForm"]').on('submit', function () {
                setAjaxCSRFToken();
                $.ajax({
                    type: 'post',
                    url: '{{ url_for("users.user-otp-enable-authentication") }}',
                    data : {
                        'password': $('input[name="password"]').val()
                    },
                    success: function (result) {
                        if (result.code != 200) {
                            bees.tipError({
                                message: result.data.message,
                            });
                        }else {
                            window.location.href = '{{ url_for("users.user-otp-enable-install-app") }}'
                        }
                    }
                });

                return false;
            })
        })

    </script>

{% endblock %}